﻿using System;
using S7.Net;

namespace S7PlcDataCollector.Models
{
    /// <summary>
    /// PLC变量实体
    /// </summary>
    public class S7PlcVariableEntity
    {
        public int Rid { get; set; }
        public int S7PlcEntityRid { get; set; }
        public string Variable { get; set; }
        public int VariableType { get; set; }
        public int Priority { get; set; }
        public string Remark { get; set; }

        public VarType VariableTypeEnum => Enum.IsDefined(typeof(VarType), VariableType)
            ? (VarType) VariableType
            : VarType.Bit;

        public S7PlcVariableEntity CloneEntity()
        {
            return new S7PlcVariableEntity()
            {
                Rid = Rid,
                S7PlcEntityRid = S7PlcEntityRid,
                Variable = Variable,
                VariableType = VariableType,
                Priority = Priority,
                Remark = Remark
            };
        }
    }
}
